package com.huobao.yunying.activitys.muyingquan;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.xutils.view.annotation.ViewInject;

import com.huobao.yunying.adapters.Adapter_Shequ_MyFaTie;
import com.huobao.yunying.base.HuobaoBaseActivity;
import com.huobao.yunying.utils.DialogUtils;
import com.huobao.yunying.utils._PopupImageString;
import com.huobao.yunying.utils.DialogUtils.DialogListener;
import com.huobao.zhangying.R;

import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;

public abstract class Act_SheQu_Base extends HuobaoBaseActivity implements OnClickListener {
	@ViewInject(R.id.lv_shequ_fatie)
	protected ListView mListView;
	@ViewInject(R.id.btn_shequfatie_back)
	protected Button Btn_Back;
	@ViewInject(R.id.btn_shequfatie_more)
	protected Button Btn_More;
	@ViewInject(R.id.linear_shequfatie)
	protected LinearLayout mLinearLayout;
	@ViewInject(R.id.shequ_title)
	protected TextView Tv_title;
	protected _PopupImageString popUtils;
	protected View footView;
	protected TextView footMsg;
	@ViewInject(R.id.shequ_empty)
    protected RelativeLayout Rel_empty;
	@Override
	protected int getContentView() {
		return R.layout.layout_shequ_fatie;
	}
	

	@Override
	protected void init() {
		Btn_Back.setOnClickListener(this);
		Btn_More.setOnClickListener(this);
		mAbTitleBar.setVisibility(View.GONE);
		footView = LayoutInflater.from(context).inflate(R.layout.item_footview, null);
		footMsg = (TextView) footView.findViewById(R.id.tv_message);
		footMsg.setText("木有更多了");
		mListView.addFooterView(footView);
		if(getTitleText() != null){
			Tv_title.setText(getTitleText());
		}
		onInit();
	}
   
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btn_shequfatie_back:
			finish();
			break;
		case R.id.btn_shequfatie_more:
			showPop();
			break;
		}
	}

	@SuppressWarnings("static-access")
	private void showPop() {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		Map<String, Object> map;

		map = new HashMap<String, Object>();
		map.put("text", "全部删除");
		map.put("image", R.mipmap.clear_all);
		list.add(map);

		map = new HashMap<String, Object>();
		map.put("text", "跳页");
		map.put("image", R.mipmap.tiaoye);
		list.add(map);
		popUtils.showPop(context, list, mLinearLayout, new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				popUtils.dismiss();
				switch (position) {
				case 0:
					// 全部删除
					break;
				case 1:
					// 跳到第几页
					DialogUtils.ShowTiaoYeDialog(context, new DialogListener() {
						@Override
						public void OnSubmit(String msg) {
                          
						}

						@Override
						public void OnCancle() {

						}
					});
					break;
				}
			}
		});
	}
	
	protected abstract void onInit();

}
